import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'hx_demo_platform_interface.dart';

/// An implementation of [HxDemoPlatform] that uses method channels.
class MethodChannelHxDemo extends HxDemoPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('hx_demo');



  @override
  Future<String?> getPlatformVersion() async {
    print("getPlatformVersion");
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  /// 初始化
  /// appKey: “管理员模式 > 渠道管理 > 手机APP”页面的关联的“AppKey”
  /// tenantId: “管理员模式 > 设置 > 企业信息”页面的“租户ID”
   @override
   Future<String?> init(String appKey, String tenantId) async{
   return await methodChannel.invokeMethod<String>("init", <String, dynamic>{
      "appKey": appKey,
      "tenantId": tenantId,
    });
  }

  /// 注册
  @override
  Future<bool?> register(String username, String password) async {
    return await methodChannel.invokeMethod("register", <String, dynamic>{
      "username": username,
      "password": password,
    });
  }

  /// 登录
  @override
  Future<bool?> login(String username, String password) async {
    return await methodChannel.invokeMethod("login", <String, dynamic>{
      "username": username,
      "password": password,
    });
  }

  /// 是否登录
  @override
  Future<bool?> get isLogin {
    return  methodChannel.invokeMethod("isLogin");
  }

  /// 注销登录
  @override
  Future<bool?> logout() async {
    return await methodChannel.invokeMethod("logout");
  }

}
